package com.example.demo.OtherCoding;

import java.util.ArrayList;
import java.util.List;

class Code_findDisappearedNumbers {
    public static List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        for(int i =0;i<nums.length;++i) {
            while(nums[i] != i+1 && nums[i] != nums[nums[i]-1]) {
                int tmp = nums[i];
                nums[i] = nums[tmp-1];
                nums[tmp-1] = tmp;
            }
        }
        // 0 1 2 3 4 5 6 7
        //[1,2,3,4,3,2,7,8]
        List<Integer> res = new ArrayList<>();
        for(int i =0;i<nums.length;++i) {
            if(nums[i] != i + 1) {
                res.add(i+1);
            }
        }
        return res;
    }

    public static void main(String[] args) {
        //nums = [1,1]
        //输出：[5,6]
        // 0 1 2 3 4 5 6 7
        //[4,3,2,7,8,2,3,1]
        int[] nums = {1,1};
        findDisappearedNumbers(nums);
    }
}